<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class Config extends Model
{
    protected $fillable = ['name', 'slug', 'value', 'remark', 'group'];

    public static function getByGroup($group)
    {
        return self::query()->where('group', $group)->get();
    }

    public static function get($slug)
    {
        return self::query()->where('slug', $slug)->first();
    }
    public static function initConfig()
    {
        DB::table('configs')->insert([
            [
                'id'=>1,
                'name'=>'组织名称',
                'slug'=>'org_name',
                'value'=>'信阳师范学院',
                'group'=>'org'
            ],[
                'id'=>2,
                'name'=>'组织Logo',
                'slug'=>'org_logo',
                'value'=>'',
                'group'=>'org'
            ],[
                'id'=>3,
                'name'=>'官网',
                'slug'=>'org_url',
                'value'=>'',
                'group'=>'org'
            ],
        ]);
    }
}
